<?php
include_once 'module/controls.php';
include_once 'model/upload/process.php';

$c = new controls();
$upload = new upload();

$fillUpload = $upload->FillAll();
?>
<div id="content">
    <div class="content_block">
        <h2 class="jquery_tab_title"><?php echo $phrase["manager_lienket"] ?></h2>
        <form method="post" action="<?= $url["home"] ?>/menu/upload-process" enctype="multipart/form-data">
            <?php if(mysql_num_rows($fillUpload) > 0) { ?>
                <?php $fillOne = mysql_fetch_array($fillUpload); ?>
                <p>
                    <?php echo $c->get_textHidden("id", "{$fillOne["upload_id"]}") ?>
                    <?php echo $c->get_label($phrase["upload_url"]) ?>
                    <?php echo $c->get_textReadOnly("upload_url", "{$fillOne["upload_url"]}") ?>
                    <input class="button" type="button" value="Browser" onclick="BrowseServer();" />
                </p>
                <p>
                    <?php echo $c->get_button("update", $phrase["update"]) ?>
                </p>
            <?php } else { ?>
                <p>
                    <?php echo $c->get_label($phrase["upload_url"]) ?>
                    <?php echo $c->get_textReadOnly("upload_url") ?>
                    <input class="button" type="button" value="Browser" onclick="BrowseServer();" />
                </p>
                <p>
                    <?php echo $c->get_button("accept", $phrase["accept"]) ?>
                </p>
            <?php } ?>
        </form>
    </div>
</div>
<script>
    function BrowseServer()
    {
        // You can use the "CKFinder" class to render CKFinder in a page:
        var finder = new CKFinder();
        finder.basePath = "<?= $url["home"] ?>/js/ckfinder/";	// The path for the installation of CKFinder (default = "/ckfinder/").
        finder.selectActionFunction = SetFileField;
        finder.popup();
    }

    // This is a sample function which is called when a file is selected in CKFinder.
    function SetFileField( fileUrl )
    {
        $('#upload_url').val(fileUrl);
    }
    
    $('#accept').click(function(){
        
    });
</script>